<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page contentType="text/html; charset=UTF-8" %>  
<%@ page import="com.somapait.nsurex.core.security.systemconfig.service.SystemConfigManager"%>
<%@page import="com.somapait.nsurex.core.domain.BeanParameter"%>

<%
int timeSession = 100; // Integer.parseInt(configSystem.getConnectionTimeOut());
timeSession = timeSession-2;
timeSession = timeSession*60;

pageContext.setAttribute("device", BeanParameter.getDevice(),PageContext.PAGE_SCOPE);
%>

<script language="javascript" src="<s:url value='/js/jquery-1.7.1.min.js' />"></script>
<script language="javascript">
var conLanguageId = 1;
<s:if test="%{#session.user.language != ''}">
	conLanguageId = <s:property value='%{#session.user.language}'/>;
</s:if>

var timeSession = <%=timeSession%>; //From Sec_config_system Minute
var timePage = setSessionTime();
function setSessionTime(){
	window.setTimeout("checkSession()",timeSession*1000);
	var m;if(window.dialogArguments != null){m=window.dialogArguments;}else{m=window.opener;}
	if(m != null){
		if(m.document.headerMain != undefined){
			window.clearTimeout(m.timePage);
		}else{
			//m.setSessionTime();
		}
	}
}
function checkSession(){
	var m;if(window.dialogArguments != null){m=window.dialogArguments;}else{m=window.opener;}
	//Open Popup Confirm Session
	var url = "<s:url value='/session/continueSessionPopup.jsp' />";
	url+="?date="+new Date().toString();

	var left = (screen.width/2)-(400/2);
  	var top = (screen.height/2)-(300/2);
    var feature = " dialogWidth: 400px;dialogHeight :200px; center:yes;dialogLeft:" +left + ";dialogTop:" +top + ";";
	var resultPopup = window.showModalDialog(url,window,feature);
	if(resultPopup == 'Y'){
		setSessionTime();
	}else{
		if(m.document.headerMain != undefined){
			m.document.headerMain.action = "<s:url value='/login/login.do?logOff=Y' />";
			m.document.headerMain.submit();
			self.close();
		}else{
			m.clearSession();
			window.close();
		}
	}
}

function clearSession(){
	var m;if(window.dialogArguments != null){m=window.dialogArguments;}else{m=window.opener;}
	if(m.document.headerMain != undefined){
		m.document.headerMain.action = "<s:url value='/login/login.do?logOff=Y' />";
		m.document.headerMain.submit();
	}else{
		m.clearSession();
	}
	window.close();
}
</script>

<html>
<head>
	<title><decorator:title default="NSureX Management System" /></title>
	<decorator:head />
</head>

<s:if test='%{!#attr.device.equals("T")}'>
	<link href="<s:url value='/css/default.css' />" rel="stylesheet" type="text/css">			
</s:if>
<s:else>
	<link href="<s:url value='/css/default-tablet.css' />" rel="stylesheet" type="text/css">
</s:else>

<body onload="sf();" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
	<s:include value="/jsp/template/headerPopup.jsp">
		<s:param name="functioncodeM" value="%{functioncode}"/>
		<s:param name="captionbar" value="%{captionbar}"/>
	</s:include>
	<hr>
	<decorator:body></decorator:body>
</body>
</html>